/**
 * 上午11:05:29
 */
package com.hsnn.medstgmini.settlement.controller;

import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.base.std.model.HospInfo;
import com.hsnn.medstgmini.model.Whether;
import com.hsnn.medstgmini.settlement.model.SetAcctInfo;
import com.hsnn.medstgmini.settlement.model.SetAcctTransInfo;
import com.hsnn.medstgmini.settlement.model.SetBankAcctInfo;
import com.hsnn.medstgmini.settlement.model.SetPostOrder;
import com.hsnn.medstgmini.settlement.model.SetRelationship;
import com.hsnn.medstgmini.settlement.model.TransType;
import com.hsnn.medstgmini.settlement.service.PostOrderManager;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;
import com.hsnn.medstgmini.util.ParseNumber;


@Controller
@RequestMapping("/postOrder")
public class PostOrderController {

	private static final Logger log = Logger.getLogger(PostOrderController.class);

	@Autowired
	private PostOrderManager postOrderManager;

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private HttpSession session;
	
	
	private SysUser getSysUser(){
		return (SysUser) request.getSession().getAttribute(Constants.USERINFO);
	}
	//获取当前账户身份id
	public String getSettleAcctId(){
		String settleAcctId = "";
		if (getSysUser().getMain() == Whether.yes.getKey()) {
			settleAcctId = getSysUser().getId();
		} else { // 非主帐号获取主帐号帐户信息
			settleAcctId = getSysUser().getRootUser().getId();
		}
		return settleAcctId;
	}
	
	/**
	 * @category 跳转至医疗机构缴款单页面[中心端]
	 * @author 应晓川
	 * @date 2015年7月9日
	 * @return
	 */
	@RequestMapping("/toPostOrderForHosp")
	public String toPostOrderForHosp() {
		request.setAttribute("postOrderType","1");
		return "/settle/postOrder";
	}
	
	/**
	 * @category 跳转至核算中心缴款单页面[中心端]
	 * @author 应晓川
	 * @date 2015年7月9日
	 * @return
	 */
	@RequestMapping("/toPostOrderForSetCenter")
	public String toPostOrderForSetCenter() {
		request.setAttribute("postOrderType","2");
		return "/settle/postOrder";
	}

	/**
	 * @category 获取缴款单数据[中心端]
	 * @author 应晓川
	 * @date 2015年7月9日
	 * @return
	 */
	@RequestMapping("/getPostOrderList")
	@ResponseBody
	public Pagination getPostOrderList() {
		log.info("enter getOrdersDetailListOld method");
		String zxId = getSysUser().getId();
		Pagination page = new Pagination(request);
		String postOrderCode = request.getParameter("postOrderCode");
		String status = request.getParameter("status");
		String submitStartDatetime = request.getParameter("submitStartDatetime");
		String submitEndDatetime = request.getParameter("submitEndDatetime");
		try {
			if(postOrderCode!=null&&!"".equals(postOrderCode)){
				page.getConditions().put("postOrderCode", postOrderCode.trim());
			}
			if(status!=null&&!"".equals(status)){
				page.getConditions().put("status", status.trim());
			}
			if(submitStartDatetime!=null&&!"".equals(submitStartDatetime)){
				page.getConditions().put("submitStartDatetime", submitStartDatetime.trim());
			}
			if(submitEndDatetime!=null&&!"".equals(submitEndDatetime)){
				page.getConditions().put("submitEndDatetime", submitEndDatetime.trim());
			}
			page.getConditions().put("postOrderType", request.getParameter("postOrderType"));
			page.getConditions().put("zxId", zxId);
			page = postOrderManager.getPostOrderList(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 跳转至医疗机构审核缴款单页面[采购中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toAuditPostOrderListForHosp")
	public String toAuditPostOrderListForHosp() {
		request.setAttribute("postOrderType","1");
		return "/settle/auditPostOrderListByCenter";
	}
	
	/**
	 * @category 跳转至核算中心审核缴款单页面[采购中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toAuditPostOrderListForSetCenter")
	public String toAuditPostOrderListForSetCenter() {
		request.setAttribute("postOrderType","2");
		return "/settle/auditPostOrderListByCenter";
	}

	/**
	 * @category 获取未审核的缴款单数据[采购中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/getAuditPostOrderListByCenter")
	@ResponseBody
	public Pagination getAuditPostOrderListByCenter() {
		log.info("enter getAuditPostOrderListBySetCenter method");
		String id =  getSysUser().getId();
		Pagination page = new Pagination(request);
		String postOrderCode = request.getParameter("postOrderCode");
		String submitStartDatetime = request.getParameter("submitStartDatetime");
		String submitEndDatetime = request.getParameter("submitEndDatetime");
		try {
			if(postOrderCode!=null&&!"".equals(postOrderCode)){
				page.getConditions().put("postOrderCode", postOrderCode.trim());
			}
			if(submitStartDatetime!=null&&!"".equals(submitStartDatetime)){
				page.getConditions().put("submitStartDatetime", submitStartDatetime.trim());
			}
			if(submitEndDatetime!=null&&!"".equals(submitEndDatetime)){
				page.getConditions().put("submitEndDatetime", submitEndDatetime.trim());
			}
			page.getConditions().put("userId", id);
			page.getConditions().put("postOrderType",request.getParameter("postOrderType"));
			postOrderManager.getAuditPostOrderListByCenter(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	
	/**
	 * @category 去审核缴款单详情页面[采购中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toAuditPostOrderByCenter")
	public String toAuditPostOrderByCenter(String postOrderId) {
		SetPostOrder setPostOrder = postOrderManager.getPostOrderById(postOrderId);
		setPostOrder.setPostDatetimeStr(DateUtil.format(setPostOrder.getPostDatetime(), "yyyy-MM-dd") ); 
		request.setAttribute("setPostOrder", setPostOrder);
		return "/settle/auditPostOrderByCenter";
	}
	

	/**
	 * @category 审核缴款单数据[采购中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/auditAndSaveSetPostOrderByCenter")
	@ResponseBody
	public Pagination auditAndSaveSetPostOrderByCenter(String postOrderId,String status) {
		log.info("enter auditAndSaveSetPostOrderBySetCenter method");
		String id =  getSysUser().getId();
		Pagination page = new Pagination(request);
		try {
			String auditRemark = "" ;
			if(StringUtils.isNoneBlank(request.getParameter("auditRemark"))){
				auditRemark = request.getParameter("auditRemark");
			}
			SetPostOrder setPostOrder = postOrderManager.getSetPostOrderById(postOrderId);
			page.getConditions().put("postOrderId", postOrderId);
			page.getConditions().put("id", id);
			page.getConditions().put("auditRemark", auditRemark);
			page.getConditions().put("status", status);
			Timestamp ts = new Timestamp(System.currentTimeMillis());
			if(status.equals("1")){//通过后 做更新
						//更新医疗账户 1、根据id获取对象  2更新
					  Date now = new Date();
					  SetAcctTransInfo setAcctTransInfo = new SetAcctTransInfo();
				      SetAcctInfo setAcctInfo = postOrderManager.getSetAcctInfoById(setPostOrder.getPostOrgId());
				      setAcctInfo.setOutstandAmt(setAcctInfo.getOutstandAmt()+setPostOrder.getPostAmount());
				      setAcctInfo.setOutstandAmtUpdDttm(now);
				      setAcctInfo.setAvailableAmt(setAcctInfo.getAvailableAmt()+setPostOrder.getPostAmount());
				      setAcctInfo.setAvailableAmtUpdDttm(now);
				      setAcctInfo.setUpdUser(id);
				      setAcctInfo.setUpdDatetime(now);
				      postOrderManager.updateSetAcctInfo(setAcctInfo);
				      //新增账户收支明细
				      setAcctTransInfo.setTransId(UUID.randomUUID().toString());
				      setAcctTransInfo.setOrgId(setPostOrder.getPostOrgId());//缴款机构id
				      setAcctTransInfo.setTransType(TransType.income.getKey());//收支类型1收2支3取消
				      setAcctTransInfo.setAmount(setPostOrder.getPostAmount());
				      setAcctTransInfo.setTransDatetime(now);
				      setAcctTransInfo.setOutstandAmt(setAcctInfo.getAvailableAmt());
				      setAcctTransInfo.setUpdUser(id);
				      setAcctTransInfo.setUpdDatetime(now);
				      postOrderManager.saveSetAcctTransInfo(setAcctTransInfo);
			}
			setPostOrder.setStatus(Short.parseShort(status)); //1通过 2不通过
			setPostOrder.setAuditRemark(auditRemark);
			setPostOrder.setAuditDatetime(ts);
			setPostOrder.setAuditStatus(id);
			setPostOrder.setUpdDatetime(ts);
			setPostOrder.setUpdUser(id);
			postOrderManager.updateSetPostOrder(setPostOrder);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	
//------------------医疗机构--------------------	
	/**
	 * @category 跳转至缴款单页面[医疗机构端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toPostOrderByHosp")
	public String toPostOrderByHosp() {
		return "/settle/postOrderByHosp";
	}

	/**
	 * @category 获取缴款单数据[医疗机构端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/getPostOrderListByHosp")
	@ResponseBody
	public Pagination getPostOrderListByHosp() {
		log.info("enter getPostOrderListByHosp method");
		String hospId = ((HospInfo) getSysUser().getInfo()).getHospId();
		Pagination page = new Pagination(request);
		if(StringUtils.isNotBlank(request.getParameter("postOrderCode"))){
			page.getConditions().put("postOrderCode",request.getParameter("postOrderCode"));	
		}
		if(StringUtils.isNotBlank(request.getParameter("submitStartDatetime"))){
			page.getConditions().put("submitStartDatetime",request.getParameter("submitStartDatetime"));
		}
		if(StringUtils.isNotBlank(request.getParameter("submitEndDatetime"))){
			page.getConditions().put("submitEndDatetime",request.getParameter("submitEndDatetime"));
		}
		if(StringUtils.isNotBlank(request.getParameter("status"))){
			page.getConditions().put("status",request.getParameter("status"));
		}
		try {
			page.getConditions().put("hospId", hospId);
			page = postOrderManager.getPostOrderListByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 跳转至新增缴款单页面[医疗机构端]
	 * @author 应晓川
	 * @date 2015年7月21日16:47:41
	 * @return
	 */
	@RequestMapping("/toAddPostOrderByHosp")
	public String AddPostOrderByHosp(Model model) {
		String hospId = ((HospInfo) getSysUser().getInfo()).getHospId();
		SetRelationship fatherOrg = postOrderManager.getFatherOrgId(hospId);
		List<SetBankAcctInfo> setBankAcctInfo =  postOrderManager.getSetBankAcctinfoById(hospId);
		model.addAttribute("setBankAcctInfo", setBankAcctInfo);
		model.addAttribute("fatherOrg", fatherOrg);
		return "/settle/addPostOrderByHosp";
	}
	
	
	/**
	 * @category 保存新增的缴款单[医疗机构端]
	 * @author 应晓川
	 * @date 2015年7月21日18:15:18
	 * @return
	 */
	

	@RequestMapping("/saveSetPostOrderByHosp")
	@ResponseBody
	public Pagination saveSetPostOrderByHosp(SetPostOrder setPostOrder) {
		String updUser =  getSysUser().getUpdUser();//更新人
		String hospId = ((HospInfo)getSysUser().getInfo()).getHospId();
		Pagination page = new Pagination(request);
		try {
			if (setPostOrder != null) {
				setPostOrder.setPostAmount(ParseNumber.toDouble(setPostOrder.getPostAmountStr()));
				Timestamp ts=  new Timestamp(ParseDate.fromFullFormat(setPostOrder.getPostDatetimeStr()).getTime());
				setPostOrder.setPostDatetime(ts);
				page.setForm(setPostOrder);
				page.getConditions().put("updUser", updUser);
				page.getConditions().put("id", hospId);
				page.getConditions().put("postOrderType",Constants.POST_ORDER_TYPE_HOSP);
				postOrderManager.saveSetPostOrder(page);
				page.setSuccess(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
		}
		return page;
	}
	
	@RequestMapping("/getBankAcct")
	@ResponseBody
	public SetBankAcctInfo getBankAcct() {
		SetBankAcctInfo SetBankAcctInfo = postOrderManager.getBankAcct(request.getParameter("postBankAcct"));
		return SetBankAcctInfo;
	}
	
	
	

//------------------核算中心--------------------
	/**
	 * @category 跳转至缴款单页面[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toPostOrderBySetCenter")
	public String toPostOrderBySetCenter() {
		return "/settle/postOrderBySetCenter";
	}

	/**
	 * @category 获取我的缴款单数据[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/getPostOrderListBySetCenter")
	@ResponseBody 
	public Pagination getPostOrderListBySetCenter() {
		log.info("enter getPostOrderListBySetCenter method");
		String id =  getSysUser().getId();
		Pagination page = new Pagination(request);
		if(StringUtils.isNotBlank(request.getParameter("postOrderCode"))){
			page.getConditions().put("postOrderCode",request.getParameter("postOrderCode"));	
		}
		if(StringUtils.isNotBlank(request.getParameter("submitStartDatetime"))){
			page.getConditions().put("submitStartDatetime",request.getParameter("submitStartDatetime"));
		}
		if(StringUtils.isNotBlank(request.getParameter("submitEndDatetime"))){
			page.getConditions().put("submitEndDatetime",request.getParameter("submitEndDatetime"));
		}
		if(StringUtils.isNotBlank(request.getParameter("status"))){
			page.getConditions().put("status",request.getParameter("status"));
		}
		try {
			page.getConditions().put("userId", id);
			postOrderManager.getPostOrderListBySetCenter(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 跳转至新增缴款单页面[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日16:47:41
	 * @return
	 */
	@RequestMapping("/toAddPostOrderBySetCenter")
	public String AddPostOrderBySetCenter(Model model) {
		String userId =  getSysUser().getId();
		SetRelationship fatherOrg = postOrderManager.getFatherOrgId(userId);
		List<SetBankAcctInfo> setBankAcctInfo =  postOrderManager.getSetBankAcctinfoById(userId);
		model.addAttribute("setBankAcctInfo", setBankAcctInfo.get(0));
		model.addAttribute("fatherOrg", fatherOrg);
		return "/settle/addPostOrderBySetCenter";
	}
	
	/**
	 * @category 订单名称的重复性校验
	 * @author zhoqi
	 * @date 2015年8月13日11:20:29
	 * @return
	 */
	@RequestMapping("/toTestRepeatOfBillName")
	@ResponseBody
	public Boolean toTestRepeatOfBillName(Model model) {
		String postOrderName = request.getParameter("postOrderName");
	    if(null != postOrderManager.getPostOrderByName(postOrderName)){
			 return true;
		}
		return false;
	}
	
	
	
	/**
	 * @category 保存新增的缴款单[医疗机构端]
	 * @author 应晓川
	 * @date 2015年7月21日18:15:18
	 * @return
	 */

	@RequestMapping("/saveSetPostOrderBySetCenter")
	@ResponseBody
	public Pagination saveSetPostOrderBySetCenter(SetPostOrder setPostOrder) {
		String id =  getSysUser().getId();
		String updUser =  getSysUser().getUpdUser();//更新人
		Pagination page = new Pagination(request);
		try {
			if (setPostOrder != null) {
				setPostOrder.setPostAmount(ParseNumber.toDouble(setPostOrder.getPostAmountStr()));
				Timestamp ts=  new Timestamp(ParseDate.fromFullFormat(setPostOrder.getPostDatetimeStr()).getTime());
				setPostOrder.setPostDatetime(ts);
				page.setForm(setPostOrder);
				page.setForm(setPostOrder);
				page.getConditions().put("id", id);
				page.getConditions().put("updUser", updUser);
				page.getConditions().put("postOrderType",Constants.POST_ORDER_TYPE_HS);
				postOrderManager.saveSetPostOrder(page);
				page.setSuccess(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
		}
		return page;
	}
	
	
	
	/**
	 * @category 跳转至审核缴款单页面[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toAuditPostOrderListBySetCenter")
	public String toAuditPostOrderListBySetCenter() {
		return "/settle/auditPostOrderListBySetCenter";
	}

	/**
	 * @category 获取未审核的缴款单数据[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/getAuditPostOrderListBySetCenter")
	@ResponseBody
	public Pagination getAuditPostOrderListBySetCenter() {
		log.info("enter getAuditPostOrderListBySetCenter method");
		String id =  getSysUser().getId();
		Pagination page = new Pagination(request);
		if(StringUtils.isNotBlank(request.getParameter("postOrderCode"))){
			page.getConditions().put("postOrderCode",request.getParameter("postOrderCode"));	
		}
		if(StringUtils.isNotBlank(request.getParameter("submitStartDatetime"))){
			page.getConditions().put("submitStartDatetime",request.getParameter("submitStartDatetime"));
		}
		if(StringUtils.isNotBlank(request.getParameter("submitEndDatetime"))){
			page.getConditions().put("submitEndDatetime",request.getParameter("submitEndDatetime"));
		}
		try {
			page.getConditions().put("userId", id);
			postOrderManager.getAuditPostOrderListBySetCenter(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * @category 跳转至查看缴款单页面[核算中心端]
	 * @author wangbing
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toSeePostOrderListBySetCenter")
	public String toSeePostOrderListBySetCenter() {
		return "/settle/seePostOrderListBySetCenter";
	}
	
	/**
	 * @category 获取查看缴款单数据[核算中心端]
	 * @author wangbing
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/getSeePostOrderListBySetCenter")
	@ResponseBody
	public Pagination getSeePostOrderListBySetCenter() {
		log.info("enter getSeePostOrderListBySetCenter method");
		String id =  getSysUser().getId();
		Pagination page = new Pagination(request);
		if(StringUtils.isNotBlank(request.getParameter("postOrderCode"))){
			page.getConditions().put("postOrderCode",request.getParameter("postOrderCode"));	
		}
		if(StringUtils.isNotBlank(request.getParameter("submitStartDatetime"))){
			page.getConditions().put("submitStartDatetime",request.getParameter("submitStartDatetime"));
		}
		if(StringUtils.isNotBlank(request.getParameter("submitEndDatetime"))){
			page.getConditions().put("submitEndDatetime",request.getParameter("submitEndDatetime"));
		}
		page.getConditions().put("orderPostStatus", "all");
		try {
			page.getConditions().put("userId", id);
			postOrderManager.getAuditPostOrderListBySetCenter(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 去审核缴款单详情页面[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/toAuditPostOrderBySetCenter")
	public String toAuditPostOrderBySetCenter(String postOrderId) {
//		Pagination page = new Pagination(request);
//		String id =  getSysUser().getId();
//		page.getConditions().put("postOrderId", postOrderId);
//		page.getConditions().put("id", id);
//		page = postOrderManager.getSetPostOrderByPage(page);
//		List<Object> list  = null;
//		if(page.getRows()!=null){
//			 list  =  (List<Object>) page.getRows();
//		}
//		request.setAttribute("obj",list.get(0) );
//		return "/settle/auditPostOrderBySetCenter";
//		
//		
		SetPostOrder setPostOrder = postOrderManager.getPostOrderById(postOrderId);
		setPostOrder.setPostDatetimeStr(DateUtil.format(setPostOrder.getPostDatetime(), "yyyy-MM-dd") ); 
		String postAmount = new DecimalFormat("0.00").format(setPostOrder.getPostAmount());
		request.setAttribute("setPostOrder", setPostOrder);
		request.setAttribute("postAmount", postAmount);
		return "/settle/auditPostOrderByCenter";
	}
	

	/**
	 * @category 审核缴款单数据[核算中心端]
	 * @author 应晓川
	 * @date 2015年7月21日13:26:54
	 * @return
	 */
	@RequestMapping("/auditAndSaveSetPostOrderBySetCenter")
	@ResponseBody
	public Pagination auditAndSaveSetPostOrderBySetCenter(String postOrderId,String status) {
		log.info("enter auditAndSaveSetPostOrderBySetCenter method");
		String id =  getSysUser().getId();
		Pagination page = new Pagination(request);
		try {
			String auditRemark = "" ;
			if(StringUtils.isNoneBlank(request.getParameter("auditRemark"))){
				auditRemark = request.getParameter("auditRemark");
			}
			SetPostOrder setPostOrder = postOrderManager.getSetPostOrderById(postOrderId);
			page.getConditions().put("postOrderId", postOrderId);
			page.getConditions().put("id", id);
			page.getConditions().put("auditRemark", auditRemark);
			page.getConditions().put("status", status);
			Timestamp ts = new Timestamp(System.currentTimeMillis());
			if(status.equals("1")){//通过后 做更新
						//更新医疗账户 1、根据id获取对象  2更新
					  Date now = new Date();
					  SetAcctTransInfo setAcctTransInfo = new SetAcctTransInfo();
				      SetAcctInfo setAcctInfo = postOrderManager.getSetAcctInfoById(setPostOrder.getPostOrgId());
				      setAcctInfo.setOutstandAmt(setAcctInfo.getOutstandAmt()+setPostOrder.getPostAmount());
				      setAcctInfo.setOutstandAmtUpdDttm(now);
				      setAcctInfo.setAvailableAmt(setAcctInfo.getAvailableAmt()+setPostOrder.getPostAmount());
				      setAcctInfo.setAvailableAmtUpdDttm(now);
				      setAcctInfo.setUpdUser(id);
				      setAcctInfo.setUpdDatetime(now);
				      postOrderManager.updateSetAcctInfo(setAcctInfo);
				      //新增账户收支明细
				      setAcctTransInfo.setTransId(UUID.randomUUID().toString());
				      setAcctTransInfo.setOrgId(setPostOrder.getPostOrgId());//缴款机构id
				      setAcctTransInfo.setTransType(TransType.income.getKey());//收支类型1收2支3取消
				      setAcctTransInfo.setAmount(setPostOrder.getPostAmount());
				      setAcctTransInfo.setTransDatetime(now);
				      setAcctTransInfo.setOutstandAmt(setAcctInfo.getAvailableAmt());
				      setAcctTransInfo.setUpdUser(id);
				      setAcctTransInfo.setUpdDatetime(now);
				      postOrderManager.saveSetAcctTransInfo(setAcctTransInfo);
			}
			setPostOrder.setStatus(Short.parseShort(status)); //1通过 2不通过
			setPostOrder.setAuditRemark(auditRemark);
			setPostOrder.setAuditDatetime(ts);
			setPostOrder.setAuditStatus(id);
			setPostOrder.setUpdDatetime(ts);
			setPostOrder.setUpdUser(id);
			postOrderManager.updateSetPostOrder(setPostOrder);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	//private 

}
